/**
 * 判断是否为空对象
 * @param {*} obj 
 * @returns 
 */
export const isEmptyObject = (obj) => {
    let name;
    for (name in obj) {
        return false;
    }
    return true;
};

/**
 * 判断类型
 * @param {*} obj 
 * @returns 
 */
export const dataOftype = (obj) => {
    let class2type = {}, core_toString = class2type.toString;
    if (obj == null) {
        return String(obj);
    }
    // Safari < 5
    return typeof obj === "object" || typeof obj === "function" ?
        class2type[core_toString.call(obj)] || "object" :
        typeof obj;
};

export function is(obj, type) {
    return (
        Object.prototype.toString.call(obj).toLowerCase() ===
        `[object ${type.toLowerCase()}]`
    )
}

export function isFunction(obj) {
    return typeof obj == 'function'
}

export {
    isEmptyObject,
    dataOftype,
    is,
    isFunction
}